package com.baor.controller;

import com.baor.domain.CarVo;
import com.baor.domain.OrderVo;
import com.baor.domain.UserVo;
import com.baor.service.LittleService;
import com.baor.utils.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

import static com.baor.utils.DateUtil.now;

@RestController
@RequestMapping
public class LittleController {

    @Autowired
    private LittleService service;

    @RequestMapping("disCenter")
    public AjaxResult<?> disCenter(@RequestBody Map<String,Object> map){
        return service.disCenter(map);
    }

    @RequestMapping("details")
    public AjaxResult<?> details(@RequestBody Map<String,Object> map){
        return service.details(map);
    }

    @RequestMapping("disOrder")
    public AjaxResult<?> disOrder(@RequestBody Map<String,Object> map){
        return service.disOrder(map);
    }

    @RequestMapping("disGoods")
    public AjaxResult<?> disGoods(@RequestBody Map<String,Object> map){
        return service.disGoods(map);
    }

    @Scheduled(cron = "0 0 0 * * *")
    public void schedule(){
        System.out.println(now() + "~");
    }

//    @RequestMapping("shopCar")
//    public AjaxResult<?> shopCar(@RequestBody List<OrderVo> list){
//        return service.shopCar(list);
//    }
//
//    @RequestMapping("shoping")
//    public AjaxResult<?> shoping(@RequestBody List<OrderVo> list){
//        return service.shoping(list);
//    }

    @RequestMapping("updateCar")
    public AjaxResult<?> updateCar(@RequestBody List<CarVo> list){
        return service.updateCar(list);
    }

    @RequestMapping("deleteCar")
    public AjaxResult<?> deleteCar(@RequestBody List<CarVo> list){
        return service.deleteCar(list);
    }
    @RequestMapping("addCar")
    public AjaxResult<?> shoping(@RequestBody CarVo carVo){
        return service.addCar(carVo);
    }

    @RequestMapping("carList")
    public AjaxResult<?> carList(@RequestBody CarVo carVo){
        return service.carList(carVo);
    }

    @RequestMapping("getTwo")
    public AjaxResult<?> getTwo(@RequestBody UserVo userVo){
        return service.getTwo(userVo);
    }

//    @RequestMapping("createCar")
//    public AjaxResult<?> createCar(@RequestBody Map<String,Object> map){
//        return service.createCar(map);
//    }
//
//    @RequestMapping("desCar")
//    public AjaxResult<?> desCar(@RequestBody Map<String,Object> map){
//        return service.desCar(map);
//    }

    @RequestMapping("getObject")
    public AjaxResult<?> getObject(@RequestBody Object o){
        System.out.println(o);
        System.out.println(o.getClass());
        return AjaxResult.success(o);
    }


    @RequestMapping("/test")
    public AjaxResult<?> test(){
        return service.test();
    }
}



